package com.li.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.li.service.OrderSettingService;
import com.li.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CleanOrderSetting4LastDayOfMonth {

    @Reference
    private OrderSettingService orderSettingService;

    // 定时清理预约设置(清理上个月的预约设置)
    public void CleanOrderSetting() {
        try {
            // 获取上一个月
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.MONTH, -1);
            Date date = calendar.getTime();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            String time = sdf.format(date) + "-31";

            orderSettingService.delete4Month(time);
            System.out.println("已清理" + time + "及之前的预约设置");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
